package com.story.core.exception;

/**
 * @author Administrator
 * @decription
 * @Date 2017-11-28 15:23
 */
public class StoryException extends RuntimeException {

    /**
     * 友好提示的code码
     */
    protected int friendlyCode;

    /**
     * 友好提示
     */
    protected String friendlyMsg;

    /**
     * 业务异常跳转的页面
     */
    protected String urlPath;

    protected StoryException(int friendlyCode, String friendlyMsg, String urlPath) {
        this.setValues(friendlyCode, friendlyMsg, urlPath);
    }

    public StoryException(int friendlyCode, String friendlyMsg) {
        this.setValues(friendlyCode, friendlyMsg);
    }

    public StoryException(StoryExceptionEnum bizExceptionEnum) {
        this.setValues(bizExceptionEnum.getCode(), bizExceptionEnum.getMessage(), bizExceptionEnum.getUrlPath());
    }

    private void setValues(int friendlyCode, String friendlyMsg, String urlPath) {
        this.friendlyCode = friendlyCode;
        this.friendlyMsg = friendlyMsg;
        this.urlPath = urlPath;
    }

    private void setValues(int friendlyCode, String friendlyMsg) {
        this.friendlyCode = friendlyCode;
        this.friendlyMsg = friendlyMsg;
    }

    public int getCode() {
        return friendlyCode;
    }

    public void setCode(int code) {
        this.friendlyCode = code;
    }

    @Override
    public String getMessage() {
        return friendlyMsg;
    }

    public void setMessage(String message) {
        this.friendlyMsg = message;
    }

    public String getUrlPath() {
        return urlPath;
    }

    public void setUrlPath(String urlPath) {
        this.urlPath = urlPath;
    }
}
